package com.finace.money.ui.activity;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.finace.money.R;
import com.finace.money.common.Constant;
import com.finace.money.common.util.ACache;
import com.finace.money.di.component.AppComponent;
import com.finace.money.ui.adapter.GuidePagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by S on 2018/2/24.
 */

public class GuideActivity extends BaseActivity{
    @BindView(R.id.vp_guide)
    ViewPager vpGuide;
    @BindView(R.id.container)
    LinearLayout container;

    private List<ImageView> imageViews;
    private GuidePagerAdapter adapter;

    @Override
    public int setLayout() {
        return R.layout.activity_guide;
    }

    @Override
    public void init() {

        imageViews = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            ImageView imageView = new ImageView(this);
            if (i == 0) {
                imageView.setImageResource(R.drawable.guide_one);
            } else if (i == 1) {
                imageView.setImageResource(R.drawable.guide_two);
                imageView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        container.removeAllViews();
                        ACache.get(GuideActivity.this).put(Constant.firstIn, "1");
                        Intent intent = new Intent(GuideActivity.this, MainActivity.class);
                        startActivity(intent);
                        finish();
                    }
                });
            }
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageViews.add(imageView);
        }
        adapter = new GuidePagerAdapter(imageViews);
        vpGuide.setAdapter(adapter);

    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }
}
